#include"process.h"

#define TARGET_SIZE 1024*1024
#define DSIZE 1024*10


//void download()
//{
//    int target = TARGET_SIZE;
//    int total = 0;
//    while(total < target)
//    {
//        usleep(STIME);
//        total += DSIZE;
//        process_v2(total * 100/target);
//    }
//    printf("\n");
//}

void download(callback_t cb)
{
    float target = TARGET_SIZE;
    float total = 0;
    while(total < target)
    {
        usleep(STIME);
        total += DSIZE;
        float rate = total * 100 / target;
       // if(rate > 50)
       // {
       //     total = target / 2;
       // }
        cb(rate);
    }
    cb(MAX_SIZE);
    printf("\n");
}


int main()
{
    download(process_v2);
    return 0;
}                         
